package com.wjd.client;

import com.jfinal.core.Controller;
import com.wjd.engine.SearchEngine;
import com.wjd.engine.SearchResult;
import com.wjd.parser.ChineseParser;

public class CliController extends Controller {

    private Boolean issearch = false;

    public void index() {
        issearch = false;
        this.setAttr("search", issearch);
        this.render("index.html");
    }

    public void find() {
        String words = this.getPara("keys");

        // 查找并得到Results数组
        SearchEngine search = new SearchEngine();

        String keyWord = new ChineseParser().getKeyWords(words);
        SearchResult[] Searcher = search.search(words);

        issearch = true;
        this.setAttr("search", issearch);
        this.setAttr("keyWord", keyWord);
        this.setAttr("webinformation", Searcher);
        this.render("main.jsp");
    }
}
